package org.xczy.boot.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.xczy.boot.config.RabbitMQConfig;

import javax.annotation.Resource;

@RestController
@RequestMapping("/producer")
@Slf4j
public class TestController {

  @Resource
  private RabbitTemplate rabbitTemplate;

  @GetMapping("/{id}")
  public Integer getProducer(@PathVariable("id") Integer id){
    rabbitTemplate.convertAndSend(RabbitMQConfig.EXCHANGE_NAME,"boot",id + "叙叙");
    log.info("生产者为：{}", id);
    return id;
  }

}
